package com.boo.service;

import org.json.JSONArray;
import org.json.JSONObject;

import android.util.Log;

import com.loopj.android.http.JsonHttpResponseHandler;
import com.thuanhoang.boo.HomeActivity;

/**
 * Get user service - authentication service
 * 
 * @author ThuanHM <thuanhm@vnext.vn>
 * @since 2013/12/27
 * */
public class MerchService extends BaseService {
	private HomeActivity home;

	public MerchService(HomeActivity parentActivity) {
		super(parentActivity);
		this.home = parentActivity;
	}


	public void getData(final String url){
		try{
			this.get(parentActivity,url, new JsonHttpResponseHandler() {
				@Override
				public void onSuccess(JSONArray response){
					//Log.d("get merch", " is " + response);
				}
				@Override
				public void onSuccess(JSONObject response) {
					//Log.d("get merch", " is " + response);
					//home.afterMerch(response);
					setCache(url, response.toString());
				}

				@Override
				public void onFailure(Throwable error) {
					//Log.d("failure", "is " + error.getMessage());
					error.printStackTrace();
				}
			});
		}
		catch (Exception e){
			Log.d("error", "is " + e.getMessage());
		}
	}
}